﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using PowerHub.MES.Common.Utility;
using PowerHub.MES.DTO.BasicData.DTO;
using PowerHub.MES.DTO.BasicData.QueryDto;
using PowerHub.MES.Entities.BasicData;
using PowerHub.MES.IServices.IBasic;
using PowerHub.MES.ReturnEntity;

namespace PowerHub.MES.Controllers.Basic
{

    /// <summary>
    /// 计量单位
    /// </summary>
    [ApiController]
    [Route("Api/MES/Basic/[controller]/[action]")]
    public class MeasuringUnitController
    {

        private IBasicData_MeasuringUnitServices _MeasuringUnitServices;

        public MeasuringUnitController(IBasicData_MeasuringUnitServices MeasuringUnitServices)
        {
            _MeasuringUnitServices = MeasuringUnitServices;
        }

        /// <summary>
        /// 获取计量单位列表
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("获取计量单位列表")]
        public async Task<OperationPageResult<List<BasicData_MeasuringUnit>>> GetBasicData_MeasuringUnitPageListAsync([FromBody] QueryBasicData_MeasuringUnitDTO pageQuery)
        {
            return await _MeasuringUnitServices.GetBasicData_MeasuringUnitPageListAsync(pageQuery);
        }


        /// <summary>
        /// 批量删除计量单位
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("批量删除计量单位")]
        public async Task<OperationResult<object>> BatchDeletionBasicData_MeasuringUnitAsync([FromBody] List<string>  Query)
        {
            return await _MeasuringUnitServices.BatchDeletionBasicData_MeasuringUnitAsync(Query);
        }

        /// <summary>
        /// 更新计量单位
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("更新计量单位")]
        public async Task<OperationResult<object>> UpdateBasicData_MeasuringUnitAsync([FromBody] BasicData_MeasuringUnitDTO Query)
        {
            return await _MeasuringUnitServices.UpdateBasicData_MeasuringUnitAsync(Query);
        }

        /// <summary>
        /// 添加计量单位
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("添加计量单位")]
        public async Task<OperationResult<object>> CreateBasicData_MeasuringUnitAsync([FromBody] BasicData_MeasuringUnitDTO Query)
        {
            return await _MeasuringUnitServices.CreateBasicData_MeasuringUnitAsync(Query);
        }
    }
}
